const root = {
  val: 'A',
  left: {
    val: 'B',
    left: {
      val: 'D'
    },
    right: {
      val: 'E'
    }
  },
  right: {
    val: 'C'
  }
}

function preorder(root) {
  if (!root) return
  else console.log(root.val)
  preorder(root.left)
  preorder(root.right)
}

function inorder(root) {
  if (!root) return
  inorder(root.left)
  console.log(root.val)
  inorder(root.right)
}

function order(root) {
  if (!root) return
  order(root.left)
  order(root.right)
  console.log(root.val)
}